package com.example.light.web.meeting.controller;

import com.example.light.web.meeting.dao.OaRoomMapper;
import com.example.light.web.meeting.entity.OaRoom;
import com.example.light.web.meeting.service.PreorderService;
import com.example.light.web.system.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class PreorderController {

    @Autowired
    private PreorderService preorderService;

    @RequestMapping("toPreorder")
    String toPreorder(Model model){
        preorderService.preorderList(model);
        return "meeting/meet_room/meeting_preorder";
    }

    @RequestMapping("toAddPreorder")
    String toAddPreorder(){
        return "/meeting/meet_room/meeting_preorder_add";
    }

    @RequestMapping("addPreorder")
    @ResponseBody
    String addPreorder(int Id, HttpSession session){
        try {
            User user=(User) session.getAttribute("user");
            String str=preorderService.addPreorder(Id,user);
            return str;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "失败";
    }

    @RequestMapping("delPreorder")
    @ResponseBody
    String delPreorder(int delInfo,HttpSession session){
        try {
            User user=(User) session.getAttribute("user");
            String str= preorderService.delPreorder(delInfo,user);
            return str;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "失败";
    }

}
